package com.guli.generator.service.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guli.generator.mapper.EduTeacherMapper;
import com.guli.generator.pojo.EduTeacher;
import com.guli.generator.pojo.vo.TeacherQuery;
import com.guli.generator.service.EduTeacherService;

import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
* @author Administrator
* @description 针对表【edu_teacher(讲师)】的数据库操作Service实现
* @createDate 2021-12-28 20:25:55
*/
@Service
public class EduTeacherServiceImpl implements EduTeacherService {
    @Resource
    private EduTeacherMapper teacherMapper;
    public Page<EduTeacher> teacherList(Integer startPage, Integer endPage, TeacherQuery teacherQuery){
        Page<EduTeacher> page = new Page<>(startPage,endPage);
        QueryWrapper wrapper = new QueryWrapper();
        String name = teacherQuery.getName();
        Integer level = teacherQuery.getLevel();
        String begin = teacherQuery.getBegin();
        String end = teacherQuery.getEnd();
        if(name!=null){
            wrapper.like("name",name);
        }
        if(level!=null){
            wrapper.eq("level",level);
        }
        if(begin!=null){
            wrapper.ge("gmt_create",begin);
        }
        if(end!=null){
            wrapper.le("gmt_modified",end);
        }
        Page<EduTeacher> pageTeacher = teacherMapper.selectPage(page,wrapper);
        return pageTeacher;
    }
    public Integer deleTeacher(String id){
        Integer count = teacherMapper.deleteById(id);
        return count;
    }

    @Override
    public Integer addTeacher(EduTeacher teacher) {
        Integer count = teacherMapper.insert(teacher);
        return count;
    }

    @Override
    public EduTeacher getTeacher(String id) {
        return teacherMapper.selectById(id);
    }

    @Override
    public Integer updateTeacher(EduTeacher eduTeacher) {
        Integer count = teacherMapper.updateById(eduTeacher);
        return count;
    }
}
